|
In computer graphics, the Liang–Barsky algorithm (named after You-Dong Liang and Brian A. Barsky) is a line clipping algorithm. The Liang–Barsky algorithm uses the parametric equation of a line and inequalities describing the range of the clipping window to determine the intersections between the line and the clipping window. With these intersections it knows which portion of the line should be drawn. This algorithm is significantly more efficient than Cohen–Sutherland.The idea of the Liang-Barsky clipping algorithm is to do as much testing as possible before computing line intersections. Consider first the usual parametric form of a straight line: : : A point is in the clip window, if : and :, which can be expressed as the 4 inequalities :, where : (right) : (bottom) : (top) To compute the final line segment: # A line parallel to a clipping window edge has for that boundary. # If for that , , the line is completely outside and can be eliminated. # When the line proceeds outside to inside the clip window and when , the line proceeds inside to outside. # For nonzero , gives the intersection point. # For each line, calculate and . For , look at boundaries for which (i.e. outside to inside). Take to be the largest among . For , look at boundaries for which (i.e. inside to outside). Take to be the minimum of . If , the line is outside and therefore rejected. ==See also== Algorithms used for the same purpose: * Cyrus–Beck * Nicholl–Lee–Nicholl * Fast-clipping 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Liang–Barsky algorithm」の詳細全文を読む スポンサード リンク
|